home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / varia / interp18.lha / interp-1.8 / Symbol.cc < prev    next >
C/C++ Source or Header  |  1990-01-20  |  3KB  |  122 lines

  1. // Symbol.cc -- the definition of the member functions for class Symbol.
  2. // Copyright (C) 1989 Carey Richard Murphey.
  3. // (rich@rice.edu) 5310 Rutherglenn, Houston, TX 77096
  4.  
  5. // This program is free software; you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation; either version 1, or (at your option)
  8. // any later version.
  9.  
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. // GNU General Public License for more details.
  14.  
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program; if not, write to the Free Software
  17. // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19. #include "Symbol.h"
  20.  
  21. #if !defined(__OPTIMIZE__) || defined(INLINE)
  22. #ifndef INLINE
  23. #define INLINE
  24. #endif
  25.  
  26. // class Symbol:: 
  27. INLINE void Symbol:: assign (double p)
  28. {
  29.   cerr << "Error: Cannot assign to this symbol.\n";
  30. }
  31. INLINE void Symbol:: assign (int    p)
  32. {
  33.   cerr << "Error: Cannot assign to this symbol.\n";
  34. }
  35. INLINE Symbol:: operator double ()
  36. {
  37.   cerr << " Error: This symbol has no value.\n";
  38.   return 0.;
  39. }
  40. INLINE Symbol:: operator int    ()
  41. {
  42.   cerr << " Error: This symbol has no value.\n";
  43.   return 0;
  44. }
  45. INLINE double Symbol:: func (double p)
  46. {
  47.   cerr << " Error: This symbol is not a function.\n";
  48.   return 0.;
  49. }
  50. INLINE ostream& operator << (ostream& Stream, Symbol* p)
  51. {
  52.   return p->echo (Stream);
  53. }
  54.  
  55. // class Double_Pointer:: 
  56. INLINE void Double_Pointer:: assign (double p)
  57. {
  58.   *v.double_p = p;
  59. }
  60. INLINE void Double_Pointer:: assign (int    p)
  61. {
  62.   *v.double_p = (double) p;
  63. }
  64. INLINE Double_Pointer:: operator double ()
  65. {
  66.   return *v.double_p;
  67. }
  68. INLINE Double_Pointer:: operator int ()   
  69. {
  70.   return (int) *v.double_p;
  71. }
  72. INLINE int Double_Pointer:: type ()
  73. {
  74.   return 2;
  75. }
  76. INLINE ostream& Double_Pointer:: echo (ostream& Stream)
  77. {
  78.   return Stream << *v.double_p;
  79. }
  80.  
  81. // class Int_Pointer:: 
  82. INLINE void Int_Pointer:: assign (double p)
  83. {
  84.   *v.int_p = (int) p;
  85. }
  86. INLINE void Int_Pointer:: assign (int    p)
  87. {
  88.   *v.int_p = p;
  89. }
  90. INLINE Int_Pointer:: operator double ()
  91. {
  92.   return *v.int_p;
  93. }
  94. INLINE Int_Pointer:: operator int    ()
  95. {
  96.   return *v.int_p;
  97. }
  98. INLINE int Int_Pointer:: type ()
  99. {
  100.   return 3;
  101. }
  102. INLINE ostream& Int_Pointer:: echo (ostream& Stream)
  103. {
  104.   return Stream << *v.int_p;
  105. }
  106.  
  107. // class Function:: 
  108. INLINE double Function:: func (double p)
  109. {
  110.   return (*v.t_func_p)(p);
  111. }
  112. INLINE int Function:: type ()
  113. {
  114.   return 4;
  115. }
  116. INLINE ostream& Function:: echo (ostream& Stream)
  117. {
  118.   return Stream << "double function (double arg)";
  119. }
  120.  
  121. #endif
  122.